package com.boxin.ims.modules.wechat.utils;

import java.util.Map;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

import com.boxin.ims.modules.wechat.activity.ActivityProcessor;
import com.boxin.ims.modules.wechat.entity.Lottery;
import com.boxin.ims.modules.wechat.entity.LotteryRecord;
import com.boxin.ims.modules.wechat.entity.WechatMember;
import com.boxin.ims.modules.wechat.entity.activity.ActivityConfig;
import com.boxin.ims.modules.wechat.service.BusinessConfigService;
import com.boxin.ims.modules.wechat.service.activity.ActivityConfigService;


/**
 * 业务活动入口
 * @author xiaoqian
 *
*	2014下午2:38:10
 */
public class ActivityProcessorUtils  implements ApplicationContextAware{
	
	private static ActivityConfigService activityConfigService;

	@Override
	public void setApplicationContext(ApplicationContext applicationContext)
			throws BeansException {
		activityConfigService =  (ActivityConfigService)applicationContext.getBean("activityConfigService");
	}
	
	
	public static void startActivityProcessor(WechatMember member,ActivityConfig activityConfig,Map<String, Object> param){
		ActivityProcessor activityProcessor=(ActivityProcessor)SpringUtils.getBean(activityConfig.getActivityProcessor());
		
		activityProcessor.setActivityConfig(activityConfig);
		
		activityProcessor.setMember(member);
		activityProcessor.setParam(param);
		
		activityProcessor.process();
		
	}
	
	
	public static LotteryRecord startAnserActivityProcessor(WechatMember member,ActivityConfig activityConfig,Map<String, Object> param){
		ActivityProcessor activityProcessor=(ActivityProcessor)SpringUtils.getBean(activityConfig.getActivityProcessor());
		
		activityProcessor.setActivityConfig(activityConfig);
		
		activityProcessor.setMember(member);
		activityProcessor.setParam(param);
		
		return activityProcessor.answerProcess();
		
	}
	
	public static void startActivityProcessorList(WechatMember member){
		
	}

}
